MV_CC_FeatureLoad

MV_CC_FeatureLoad

Import camera feature files.

API Definition

int MV_CC_FeatureLoad(
  void           *handle,
  const char     *pFileName
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

pFileName

[IN] Input parameter

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

The following sample code is for reference only.

#include "MvCameraControl.h"

//Wait for key input
void WaitForKeyPress(void)
{
    while(!_kbhit())
    {
        Sleep(10);
    }
    _getch();
}
bool PrintDeviceInfo(MV_CC_DEVICE_INFO* pstMVDevInfo)
{
    if (NULL == pstMVDevInfo)
    {
        printf("The Pointer of pstMVDevInfo is NULL!\n");
        return false;
    }
    if (pstMVDevInfo->nTLayerType == MV_GIGE_DEVICE)
    {
        int nIp1 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24);
        int nIp2 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
        int nIp3 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
        int nIp4 = (pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x000000ff);

        //Print the current camera's IP address and user defined name
        printf("CurrentIp: %d.%d.%d.%d\n" , nIp1, nIp2, nIp3, nIp4);
        printf("UserDefinedName: %s\n\n" , pstMVDevInfo->SpecialInfo.stGigEInfo.chUserDefinedName);
    }
    else if (pstMVDevInfo->nTLayerType == MV_USB_DEVICE)
    {
        printf("UserDefinedName: %s\n\n", pstMVDevInfo->SpecialInfo.stUsb3VInfo.chUserDefinedName);
    }
    else
    {
        printf("Not support.\n");
    }
    return true;
}
int main()
{
    int nRet = MV_OK;
    void* handle = NULL;
    do
    {

        //Enumerate device
        MV_CC_DEVICE_INFO_LIST stDeviceList;
        memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
        nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &stDeviceList);
        if (MV_OK != nRet)
        {
            printf("Enum Devices fail! nRet [0x%x]\n", nRet);
            break;
        }
        if (stDeviceList.nDeviceNum > 0)
        {
            for (unsigned int i = 0; i < stDeviceList.nDeviceNum; i++)
            {
                 printf("[device %d]:\n", i);
                 MV_CC_DEVICE_INFO* pDeviceInfo = stDeviceList.pDeviceInfo[i];
                 if (NULL == pDeviceInfo)
                 {
                     break;
                 }
                 PrintDeviceInfo(pDeviceInfo);
             }
     }
     else
     {
         printf("Find No Devices!\n");
         break;
     }
     printf("Please Intput camera index:");
     unsigned int nIndex = 0;
     scanf("%d", &nIndex);
     if (nIndex >= stDeviceList.nDeviceNum)
     {
         printf("Intput error!\n");
         break;
     }
     //Select device and create handle
     nRet = MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]);
     if (MV_OK != nRet)
     {
         printf("Create Handle fail! nRet [0x%x]\n", nRet);
         break;
     }
     //Open camera
     nRet = MV_CC_OpenDevice(handle);
     if (MV_OK != nRet)
     {
         printf("Open Device fail! nRet [0x%x]\n", nRet);
         break;
     }
     //Export features from MVC as a file
     nRet = MV_CC_FeatureSave(handle, "FeatureFile.ini");
     if (MV_OK != nRet)
     {
          printf("Save Feature fail! nRet [0x%x]\n", nRet);
          break;
     }
     //Import features to the MVC
     nRet = MV_CC_FeatureLoad(handle, "FeatureFile.ini");
     if (MV_OK != nRet)
     {
           printf("Load Feature fail! nRet [0x%x]\n", nRet);
           break;
     }
     //Close device
     nRet = MV_CC_CloseDevice(handle);
     if (MV_OK != nRet)
     {
            printf("ClosDevice fail! nRet [0x%x]\n", nRet);
            break;
     }
     //Destroy handle
     nRet = MV_CC_DestroyHandle(handle);
     if (MV_OK != nRet)
     {
            printf("Destroy Handle fail! nRet [0x%x]\n", nRet);
            break;
     }
     while (0);
     if (nRet != MV_OK)
     {
            if (handle != NULL)
            {
                 MV_CC_DestroyHandle(handle);
                 handle = NULL;
            }
      }
      printf("Press a key to exit.\n");
      WaitForKeyPress();
      return 0;
}

MV_CC_FeatureLoad

Import camera feature files.

API Definition

int MV_CC_FeatureLoad(
  void           *handle,
  const char     *pFileName
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

pFileName

[IN] Input parameter

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

The following sample code is for reference only.

#include "MvCameraControl.h"

//Wait for key input
void WaitForKeyPress(void)
{
    while(!_kbhit())
    {
        Sleep(10);
    }
    _getch();
}
bool PrintDeviceInfo(MV_CC_DEVICE_INFO* pstMVDevInfo)
{
    if (NULL == pstMVDevInfo)
    {
        printf("The Pointer of pstMVDevInfo is NULL!\n");
        return false;
    }
    if (pstMVDevInfo->nTLayerType == MV_GIGE_DEVICE)
    {
        int nIp1 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24);
        int nIp2 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
        int nIp3 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
        int nIp4 = (pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x000000ff);

        //Print the current camera's IP address and user defined name
        printf("CurrentIp: %d.%d.%d.%d\n" , nIp1, nIp2, nIp3, nIp4);
        printf("UserDefinedName: %s\n\n" , pstMVDevInfo->SpecialInfo.stGigEInfo.chUserDefinedName);
    }
    else if (pstMVDevInfo->nTLayerType == MV_USB_DEVICE)
    {
        printf("UserDefinedName: %s\n\n", pstMVDevInfo->SpecialInfo.stUsb3VInfo.chUserDefinedName);
    }
    else
    {
        printf("Not support.\n");
    }
    return true;
}
int main()
{
    int nRet = MV_OK;
    void* handle = NULL;
    do
    {

        //Enumerate device
        MV_CC_DEVICE_INFO_LIST stDeviceList;
        memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
        nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &stDeviceList);
        if (MV_OK != nRet)
        {
            printf("Enum Devices fail! nRet [0x%x]\n", nRet);
            break;
        }
        if (stDeviceList.nDeviceNum > 0)
        {
            for (unsigned int i = 0; i < stDeviceList.nDeviceNum; i++)
            {
                 printf("[device %d]:\n", i);
                 MV_CC_DEVICE_INFO* pDeviceInfo = stDeviceList.pDeviceInfo[i];
                 if (NULL == pDeviceInfo)
                 {
                     break;
                 }
                 PrintDeviceInfo(pDeviceInfo);
             }
     }
     else
     {
         printf("Find No Devices!\n");
         break;
     }
     printf("Please Intput camera index:");
     unsigned int nIndex = 0;
     scanf("%d", &nIndex);
     if (nIndex >= stDeviceList.nDeviceNum)
     {
         printf("Intput error!\n");
         break;
     }
     //Select device and create handle
     nRet = MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]);
     if (MV_OK != nRet)
     {
         printf("Create Handle fail! nRet [0x%x]\n", nRet);
         break;
     }
     //Open camera
     nRet = MV_CC_OpenDevice(handle);
     if (MV_OK != nRet)
     {
         printf("Open Device fail! nRet [0x%x]\n", nRet);
         break;
     }
     //Export features from MVC as a file
     nRet = MV_CC_FeatureSave(handle, "FeatureFile.ini");
     if (MV_OK != nRet)
     {
          printf("Save Feature fail! nRet [0x%x]\n", nRet);
          break;
     }
     //Import features to the MVC
     nRet = MV_CC_FeatureLoad(handle, "FeatureFile.ini");
     if (MV_OK != nRet)
     {
           printf("Load Feature fail! nRet [0x%x]\n", nRet);
           break;
     }
     //Close device
     nRet = MV_CC_CloseDevice(handle);
     if (MV_OK != nRet)
     {
            printf("ClosDevice fail! nRet [0x%x]\n", nRet);
            break;
     }
     //Destroy handle
     nRet = MV_CC_DestroyHandle(handle);
     if (MV_OK != nRet)
     {
            printf("Destroy Handle fail! nRet [0x%x]\n", nRet);
            break;
     }
     while (0);
     if (nRet != MV_OK)
     {
            if (handle != NULL)
            {
                 MV_CC_DestroyHandle(handle);
                 handle = NULL;
            }
      }
      printf("Press a key to exit.\n");
      WaitForKeyPress();
      return 0;
}